import {createBrowserRouter, Link, NavLink} from 'react-router-dom'
import { ErrorBlock } from 'antd-mobile'
import App from '../App'
export const routes=createBrowserRouter([
    {
        path:'/',
        element:<App/>,
        children:[
            {
                path:'/home',
                async lazy(){
                    const  {default:Home,loader}= await import('../pages/home/Index')
                    return{
                        element:<Home/>,
                        loader
                    }
                }
            },
            {
                path:'/message',
                async lazy(){
                    const  {default:Message,loader}= await import('../pages/message/Index')
                    return{
                        element:<Message/>,
                        loader
                    }
                }
            },
            {
                path:'/my',
                async lazy(){
                    const  {default:My,loader}= await import('../pages/my/Index')
                    return{
                        element:<My/>,
                        loader
                    }
                }
            },
        ]
    },
    {
        path:'/login',
        async lazy(){
            const  {default:Login,loader}= await import('../pages/login/Index')
            return{
                element:<Login/>,
                loader
            }
        }
    },
    {
        path:'/reg',
        async lazy(){
            const  {default:Reg,loader}= await import('../pages/reg/Index')
            return{
                element:<Reg/>,
                loader
            }
        }
    },
    {
        path:'/city',
        async lazy(){
            const  {default:City,loader}= await import('../pages/city/Index')
            return{
                element:<City/>,
                loader
            }
        }
    },
    {
        path:'/cart',
        async lazy(){
            const  {default:Cart,loader}= await import('../pages/cart/Index')
            return{
                element:<Cart/>,
                loader
            }
        }
    },
    {
        path:'*',
        element:(
            <ErrorBlock status='default'
             fullPage description={<NavLink to='/home'>返回首页</NavLink>} />
        )
    }
])
export default routes;